GETLOGIN

Section: MINTLIB LIBRARY FUNCTIONS (3)
Updated: 3 March 1993
Index Return to Main Contents
 

NAME

getlogin - get login name  

SYNOPSIS

#include <unistd.h>

char *getlogin(void);
 

DESCRIPTION

getlogin returns a pointer to the user's login name. This is determined in the following way:

  - The name for the current userid is read from the
    password file using getuid and getpwuid.
  - If this fails, the environment variable USER is read.
  - If this fails, "user" is returned. This call returns a pointer to a dynamically allocated area of memory. Consecutive calls will return the same pointer.  

SEE ALSO

cuserid(3), getgrent(3), getpwent(3), getpwuid(3), getuid(3)  

NOTES

The method used to determine the user's login name, getpwuid(getuid()), is supposed to be the most reliable way. It will fail if several users have identical numerical userids, though. On System V, this routine will read from /etc/utmp in order to find out the current user's login name. This method can be fooled by changing the terminal associated with standard input, and thus is no viable alternative.
 

Index

NAME
SYNOPSIS
DESCRIPTION
SEE ALSO
NOTES

This document was created by man2html, using the manual pages.
Time: 11:14:45 GMT, June 22, 2025